﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Ketnoidulieu
{
    public partial class TreeVaList_QuanHe : Form
    {
        public TreeVaList_QuanHe()
        {
            InitializeComponent();
        }

        clssQLDiem obj = new clssQLDiem();

        private void TreeVaList_QuanHe_Load(object sender, EventArgs e)
        {
            DataSet dsSV = new DataSet();
            dsSV = obj.laydulieu("select * from sinhvien");
            hienthidanhsachsv(dsSV, tvw1);
        }

        void hienthidanhsachsv(DataSet dssv, TreeView t)
        {
            tvw1.Nodes.Clear();
            foreach (DataRow drSV in dssv.Tables[0].Rows)
            {
                TreeNode nodecha = t.Nodes.Add("Mã SV: "+drSV["masv"].ToString());
                nodecha.Tag = drSV["masv"].ToString();
                TreeNode nodecon = nodecha.Nodes.Add(drSV["tensv"].ToString());
                nodecon.Tag = drSV["tensv"].ToString();
            }
        }

        private void tvw1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            /*  if (tvw1.SelectedNode != null)
              {
                  if (tvw1.SelectedNode.Level != 0)
                  {
                      string sql = "select tenmh,diem,lanthi from monhoc,diem where monhoc.mamh=diem.mamh and masv='" + masv + "'";
                      DataSet dsSV = obj.laydulieu(sql);
                      lvw1.Items.Clear();
                      foreach (DataRow dr in dsSV.Tables[0].Rows)
                      {
                          ListViewItem lvi = new ListViewItem();
                          lvi.Text = dr["tenmh"].ToString();
                          lvi.SubItems.Add(dr["diem"].ToString());
                          lvi.SubItems.Add(dr["lanthi"].ToString());
                          lvw1.Items.Add(lvi);
                      }
                  }
              }*/
        }
    }
}
